<?php
class IndexController extends Vnf_Controller_Action {
    protected $_dir;

    public function indexAction() {
        $this->setLayout('cms');
        $this->view->currentPage = $this->_request->getParam('page');
    }

    public function centerAction() {
        echo "<hr>This content output from centerAction";
        $this->_helper->viewRenderer->setViewScriptPathSpec('cms/detail.phtml');
    }
    public function headerAction() {
        $category = new Category();

//        $root = $category->getRoot();
//        $data = $category->getTreeOfNode($root->category_id);
        $this->view->menu = $category->getMainMenu();

//        print_r($category->getMainMenu());

//        echo count($data);
//        print_r($data);
//        return;
    }

    public function footerAction() {
//        $category = new Category();

//        $root = $category->getRoot();
//        $data = $category->getTreeOfNode($root->category_id);
//        $data = $category->getCacheOfCategory();

//        print_r($category->getMainMenu());

//        echo count($data);
//        print_r($data);
//        return;
    }

    public function leftAction() {
        // set another template
        // $this->_helper->viewRenderer->setScriptAction('test');
        // :controller/:action.:suffix

        // render to another content
        //$this->_helper->viewRenderer->setViewScriptPathSpec('cms/detail.phtml');
    }

    public function rightAction() {
    }

    public function blockcmsAction() {
        @$this->view->blockParams = $params = $this->_getAllParams();
        @$this->view->module = $params['module'];
        @$this->view->controller = $params['controller'];
        @$this->view->action = $params['action'];
        @$this->view->name = $name = $params['id'];
        @$this->view->showContent = $showContent = $params['showContent'];
        @$this->view->content = $showContent = $params['content'];
        @$this->view->title = $showContent = $params['title'];

        //
        $isBlockNameAldreadyExists = false;
        // get all block has been register

        $manageBlockCms = Vnf::getBlockCms();

        // check id of block has exists in this page
        if (!array_key_exists($name, $manageBlockCms)) {
            $manageBlockCms[$name] = array('id' => $name);
            Zend_Registry::set('blockcms', $manageBlockCms);
        } else {
            $isBlockNameAldreadyExists = true;
            echo "<br>$name already exists<br>";
        }
        $this->view->isBlockNameAldreadyExists = $isBlockNameAldreadyExists;
    }

    public function endcmsAction() {
        Zend_Registry::set('blockcms', array());
    }

    public function translateAction() {
        $translate = new Zend_Translate('tmx', PATH_LANG_MODULE . 'items/english.tmx', 'en');
//        echo
    }
}